package com.tianji.remark.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author Covey
 */
@Data
@Component
@ConfigurationProperties(prefix = "liked.record")
@RefreshScope  // 支持动态刷新
public class LikedRecordConfig {

    private List<String> bizTypes;
    private Integer maxBizSize = 30;

    /**
     * 安全的获取业务类型列表
     */
    public List<String> getBizTypes() {
        if (bizTypes == null || bizTypes.isEmpty()) {
            // 返回默认值，确保不会NPE
            return List.of("QA", "NOTE");
        }
        return bizTypes;
    }

    /**
     * 安全的获取最大业务大小
     */
    public Integer getMaxBizSize() {
        return maxBizSize != null ? maxBizSize : 30;
    }

}